package cn.idietrade.idietradeusermodule8004.controller;

import cn.idietrade.common.pojo.SecondConcern;
import cn.idietrade.idietradeusermodule8004.service.SecondConcernService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/concern")
public class SecondConcernController {

    @Resource
    private SecondConcernService secondConcernService;

    @RequestMapping("/getConcern")
    public List<SecondConcern> getConcern(Integer userId){
        List<SecondConcern> list = secondConcernService.getSecondConcern(userId);
        return list;
    }

    @RequestMapping("/addConcern")
    public String addConcern(SecondConcern concern){
        int flag = secondConcernService.addConcern(concern);
        if (flag>0){
            return "添加成功";
        }else{
            return "添加失败";
        }
    }

    @RequestMapping("/delConcern")
    public String delConcern(Integer userId,Integer concernUserId){
        SecondConcern concern = new SecondConcern();
        concern.setUserId(userId);
        concern.setConcernuserid(concernUserId);
        int flag = secondConcernService.delConcern(concern);
        if (flag>0){
            return "添加成功";
        }else{
            return "添加失败";
        }
    }
}
